import { Editor_Check } from "../actionsType";


const inistate = {
    from: {
        id: "",
        name: '',
        title: "",
        area: "",
        price: "",
        content: "",
        province: "",
        city: "",
        county: "",
        word: "",
    }
}

const Check = (state = inistate, action) => {
    const { type, payload } = action;
    let { from } = state;
    switch (type) {
        //获取
        //编辑
        case Editor_Check:
            const { type, text } = payload;
            if (type) {
                from[type] = text;
            } else {
                from = {
                    name: payload.name,
                    area: payload.area,
                    price: payload.price,
                    content: payload.content,
                    title: payload.title,
                    id: payload.id,
                    province: payload.province,
                    city: payload.city,
                    county: payload.county,
                    word: payload.word,
                }
            }
            return {
                ...state,
                from,
            };
        default:
            return {
                ...state
            }
    }
}

export default Check